package leetcode.array;

import org.junit.Test;

import java.util.Arrays;

/**
 * @author mazouri
 * @create 2021-05-03 11:47
 */
public class RemoveElement_doublePointer {
    public int removeElement(int[] nums, int val) {
        int left = 0;
        int right = nums.length;
        while (left < right) {
            if (nums[left] == val) {
                nums[left] = nums[right-1];
                right--;
            } else {
                left++;
            }
        }
        return left;
    }

    @Test
    public void test() {
        System.out.println(removeElement(new int[]{1}, 1));
    }
}
